Data processing device and method of controlling the same

ABSTRACT

A data processing device includes an instruction execution unit that executes a first task, a second task and an interrupt task, a counter that counts an execution time of one of the first task and the interrupt task, a first storage unit that stores a set value to start the counter when the execution unit executes one of the first task and the interrupt task, a second storage unit that stores the set value stored in the first storage unit when the instruction execution unit switches from an execution of the first task to an execution of the second task, and a memory that stores the set value stored in the first storage unit when the instruction unit switches from the execution of the first task to an execution of the interrupt task.

The present application is a Continuation Application of U.S. patentapplication Ser. No. 14/596,972, filed on Jan. 14, 2015, which is aContinuation Application of U.S. patent application Ser. No. 12/292,208,filed on Nov. 13, 2008, now U.S. Pat. No. 8,938,742, which is based onJapanese Patent Application No. 2007-314352, filed on Dec. 5, 2007, theentire contents of which are hereby incorporated by reference.

BACKGROUND

1. Field of the Invention

The present invention relates to a data processing device and a methodof controlling the same, and more particularly, to a data processingdevice including a counter measuring an execution state of a task, and amethod of controlling the data processing device.

2. Description of Related Art

In recent years, a multi-task operation in which a plurality of tasksare operated in time division has been executed in data processingdevices such as micon. In the multi-task operation, the execution timeis allocated for each task, and when the execution time of the taskreaches a predetermined time, an interruption request is generated inthe task and the process is made back to Operating System (OS) so as toexecute other tasks again. In order to realize this technique, the dataprocessing device in which the multi-task operation is executed includesa timer measuring the execution time of each task.

This timer can be configured with software or hardware. In the case ofthe software, while an operation of switching tasks is executed insoftware, the timer cannot stop counting or restart counting. In thiscase, the measurement time may not be accurate. On the other hand, whenthe timer is implemented in the hardware, the timer can stop counting orrestart counting while the tasks are switched. Japanese UnexaminedPatent Application Publication No. 10-247146 discloses a technique inwhich the timer is formed by the hardware so as to measure the taskexecution time with accuracy.

In the technique disclosed in Japanese Unexamined Patent ApplicationPublication No. 10-247146, a Central Processing Unit (CPU) includes atimer control register. The timer control register provides a bit fordesignating whether or not a timer is operated by synchronizing with anexecution mode and a bit for designating the mode operating the timer bysynchronizing with the execution mode. When the timer is operated bysynchronizing with the execution mode, the bit designating whether ornot the timer is operated by synchronizing with the execution mode isset to 1, and when not, the bit is set to 0. The bit designating themode operating the timer by synchronizing with the execution mode is setto 1 when the timer is operated in a privilege mode, and is set to 0when operated in a non-privilege mode. In Japanese Unexamined PatentApplication Publication No. 10-247146, it is possible to accuratelymeasure the execution time of the task for each execution mode bycontrolling the operation of the timer by the CPU referring to thesebits. A technique of measuring the execution time of the task by thehardware is also disclosed in Japanese Unexamined Patent ApplicationPublication Nos. 2004-504667, 2000-322277, and 2-271437.

SUMMARY

The present inventors have found a problem as follows. In the techniquedisclosed in Japanese Unexamined Patent Application Publication No.10-247146, only the execution mode operating the timer can be selected,and it is impossible to operate the timer only for the task which isselected among a plurality of tasks included in the same execution mode.Not all the tasks executed in the data processing device have limitationin the execution time, but some tasks have no limitation in theexecution time even in the same execution mode. In the techniquedisclosed in Japanese Unexamined Patent Application Publication No.10-247146, the timer is operated regardless of the type of the tasks aslong as the tasks are included in the same execution mode, which meansthat it is impossible to control the operation mode and the stop mode ofthe timer for each task.

A first exemplary aspect of an embodiment of the present invention is adata processing device, including an instruction executing partexecuting a normal task and a management task scheduling an executionorder of the normal task by switching the normal task and the managementtask by a branch operation, a counter measuring an execution state ofthe normal task being executed in the instruction executing part, and astate controller controlling the counter in accordance with the normaltask being executed in the instruction executing part, in which theinstruction executing part determines whether the normal task to beexecuted next of a plurality of normal tasks scheduled by the managementtask is a measurement object or not, and outputs an operation signalnotifying the state controller of the determination result, and thestate controller operates the counter in accordance with the branchoperation from the management task to the normal task when it isnotified by the operation signal that the normal task to be executednext is the measurement object.

A second exemplary aspect of an embodiment of the present invention is amethod of controlling a data processing device, the data processingdevice including an instruction executing part executing a normal taskand a management task scheduling an execution order of the normal taskby switching the normal task and the management task by a branchoperation, a counter measuring an execution state of the normal taskbeing executed in the instruction executing part, and a state controllercontrolling the counter in accordance with the normal task beingexecuted in the instruction executing part, the method includingdetermining whether the normal task to be executed next of a pluralityof normal tasks scheduled by the management task is a measurement objector not, and operating the counter in accordance with the branchoperation from the management task to the normal task when the normaltask to be executed next is determined as the measurement object.

According to the data processing device and the method of controllingthe same in the present invention, it is determined whether the normaltask to be executed next is the measurement object or not, and the statecontroller operates the counter based on the determination result. Inthe present invention, when the normal task to be executed next is thetask of the measurement object, it is notified to the state controllerthat the task to be executed next is the measurement object beforeexecuting the normal task which is the measurement object. When thenormal task is the measurement object, the state controller operates thecounter in accordance with the branch operation from the management taskto the normal task. In summary, according to the data processing deviceof the present invention, it is determined whether the task to beexecuted next is the measurement object to control whether or not thecounter is to be operated based on the determination result. At thistime, according to the present invention, the counter is controlled bytask unit in the data processing device, which makes it possible toselect any task for measurement without depending on the execution modeof the task.

BRIEF DESCRIPTION OF THE DRAWINGS

The above and other exemplary aspects, advantages and features will bemore apparent from the following description of certain exemplaryembodiments taken in conjunction with the accompanying drawings, inwhich:

FIG. 1 is a block diagram of a data processing device according to afirst exemplary embodiment;

FIG. 2 is a block diagram of a state controller according to the firstexemplary embodiment;

FIG. 3 is a flow chart showing an operation of the data processingdevice when a normal task is executed in the first exemplary embodiment;

FIG. 4 is a timing chart showing the operation of the state controllerwhen the normal task is executed in the first exemplary embodiment;

FIG. 5 is a sequence diagram showing the operation of the dataprocessing device when the normal task is executed in the firstexemplary embodiment;

FIG. 6 is a flow chart showing the operation of the data processingdevice when an interruption task is generated in the first exemplaryembodiment;

FIG. 7 is a timing chart showing the operation of the state controllerwhen the interruption task is generated in the first exemplaryembodiment;

FIG. 8 is a sequence diagram showing the operation of the dataprocessing device when the interruption task is generated in the firstexemplary embodiment;

FIG. 9 is a block diagram of a data processing device according to asecond exemplary embodiment;

FIG. 10 is a block diagram of a state controller according to the secondexemplary embodiment;

FIG. 11 is a flow chart showing the operation of the data processingdevice according to the second exemplary embodiment;

FIG. 12 is a sequence diagram showing the operation of the dataprocessing device according to the second exemplary embodiment; and

FIG. 13 is a sequence diagram showing the operation of the dataprocessing device according to a third exemplary embodiment.

DETAILED DESCRIPTION OF THE EXEMPLARY EMBODIMENTS First ExemplaryEmbodiment

Hereinafter, the exemplary embodiments of the present invention will bedescribed with reference to the drawings. FIG. 1 shows a block diagramof a data processing device 1 according to the first exemplaryembodiment. As shown in FIG. 1, the data processing device 1 includes amemory 10, an instruction executing part 11, a measurement circuit 12,an interruption controller 18, and OR circuits 19 and 20.

The memory 10 stores a program regarding a task executed in theinstruction executing part 11 and intermediate information generatedduring the task operation. The instruction executing part 11 executes atask realizing a function provided by the data processing device 1. Theinstruction executing part 11 executes a management task scheduling theexecution order of tasks, a normal task in which the execution order isscheduled by the management task, and an interruption task interruptingthe management task or the normal task by switching these tasks by abranch operation. The instruction executing part 11 changes tasks to beexecute, according to an instruction of calling the normal task, aninstruction of calling a management task, an instruction of returningfrom interruption, or an interruption generation signal. In the firstexemplary embodiment, the interruption generation signal is output fromthe interruption controller 18. Further, in the following description,the management task is described as a task of realizing a schedulingfunction of a plurality of functions implemented in the Operating System(OS), for example. The normal task includes a task for realizing eachfunction of the user program and a task for realizing functions otherthan a scheduling function of the OS. In other words, even when the OSincludes a task which is operated in special modes such as a privilegemode, for example, the normal task includes a task which is operated inthese special modes. The interruption task includes a task which is notscheduled by the management task.

More specifically, when the instruction of calling the normal task isexecuted in the management task during a time at which the instructionexecuting part 11 executes the management task, the instructionexecuting part 11 switches the task to be executed from the managementtask to the normal task. The instruction executing part 11 outputs asignal of calling the normal task based on the instruction of callingthe normal task. When the instruction of calling management task isexecuted in the normal task during a time at which the instructionexecuting part 11 executes the normal task, the instruction executingpart 11 switches the task to be executed from the normal task to themanagement task. The instruction executing part 11 outputs the signal ofcalling management task based on the instruction of calling managementtask. When the interruption generation signal is received during a timeat which the instruction executing part 11 executes the management taskor the normal task, the instruction executing part 11 changes themanagement task or the normal task to the interruption task as theexecuted task. When the instruction of returning from interruption isexecuted in the interruption task during a time at which the instructionexecuting part 11 executes the interruption task, the instructionexecuting part 11 changes the executed task from the interruption taskto the management task or the normal task. The task which becomes thebranch destination after executing the interruption return instructionis the task designated by the interruption return instruction, and thistask is not necessarily the branch source task. For example, the taskmay be moved to the management task or to the normal task afterexecuting the interruption return instruction.

When the instruction executing part 11 executes the branch operationbased on the interruption return instruction or the instruction ofcalling the normal task, it calls an operation state stored value whichis memorized regarding the branch destination task. The instructionexecuting part 11 switches the executed tasks based on the operationstate stored value. Especially, the management task generates theoperation state stored value regarding the branch destination taskbefore the instruction of calling the normal task. On the other hand,when the instruction executing part 11 performs the branch operationbased on receiving of the interruption generation signal or theexecution of the instruction of calling the management task, theoperation information regarding the task being executed is stored as theoperation state stored value to switch the tasks.

The instruction executing part 11 outputs an operation signal and anevent notification signal according to the task to be executed. Theoperation signal is the control signal of the measurement circuit 12 andincludes a plurality of signals. The event notification signal notifiesthe event such as an error generated according to the task to beexecuted. The instruction executing part 11 is supplied with theoperation clock, and the instruction executing part 11 executes the taskaccording to the operation clock.

The measurement circuit 12 includes a state controller 13, a counter 14,a count value storing part 15, a comparison value storing part 16, and acomparator 17. The state controller 13 includes a first storing part anda second storing part storing the operation set value indicating whetherthe task being executed in the instruction executing part 11 is themeasurement object or not. In the first exemplary embodiment, theoperation set value is set by the operation signal output to the secondstoring part by the instruction executing part 11 before executing thenormal task. For example, when the normal task to be executed next ofthe normal tasks scheduled by the management task is the measurementobject, a first value (1, for example) indicating the execution of themeasurement is set as the operation set value; when the normal task tobe executed next is out of the measurement object, a second value (0,for example) indicating the stop of the measurement is set as theoperation set value. Then the state controller 13 moves the operationset value from the second storing part to the first storing part basedon the signal of calling the normal task or an interruption returnsignal, and moves the operation set value from the second storing partto the first storing part based on the signal of calling the managementtask or the interruption generation signal. The detailed description ofthe state controller 13 will be made later.

The counter 14 starts or stops the measurement of the execution state ofthe task executed in the instruction executing part 11 based on theoperation set value stored in the first storing part of the statecontroller 13. More specifically, the counter 14 counts one of theoperation clocks supplied to the instruction executing part 11 and theevent notification signal generated in the instruction executing part11. It is determined which of the signals is counted by the counter 14depending on the operation signal output from the instruction executingpart 11. The count of these signals is started and executed when theoperation set value stored in the first storing part is the first value,and is stopped when the operation set value stored in the first storingpart is the second value. When the operation set value is the firstvalue, the counter 14 reads out the value stored in the count valuestoring part, and outputs the value obtained by adding or subtractingthe read value as the count value. When the operation set value is thesecond value, the value is directly output as the count value withoutadding or subtracting the value read out from the count value storingpart.

The count value storing part 15 stores the count value output from thecounter 14 based on the operation signal output from the instructionexecuting part 11 or outputs the count value that is stored to thecounter 14. The comparison value storing part 16 stores the comparisonvalue in accordance with the operation signal output from theinstruction executing part 11. This comparison value is the referencevalue setting the output timing of a measurement interruption requestsignal. The comparator 17 outputs the comparison match result of thecount value and the comparison value as the measurement interruptionrequest signal. More specifically, the comparator 17 outputs themeasurement interruption request signal when the count value is thevalue equal to or more than the comparison value.

The interruption controller 18 outputs the interruption generationsignal based on the measurement interruption request signal output fromthe comparator 17 or the interruption request signals output from otherperipheral devices. The OR circuit 19 outputs a result of performing theOR operation on the signal of calling normal task and the interruptionreturn signal as a state setting signal. The OR circuit 20 outputs aresult of performing the OR operation on the interruption generationsignal and the signal of calling management task as the state storingsignal.

The detail of the state controller 13 will be described. FIG. 2 shows ablock diagram of the state controller 13. As shown in FIG. 2, the statecontroller 13 includes AND circuits 21 and 22, a first storing part 23,and a second storing part 24. The AND circuit 21 receives the statesetting signal and the output signal of the second storing part 24. TheAND circuit 21 outputs a result of performing the AND operation on thetwo signals as a set signal S1. Note that the state setting signal issupplied to the second storing part 24 as a reset signal R2. The ANDcircuit 22 receives the state storing signal and the output signal ofthe first storing part 23. The AND circuit 22 outputs the result ofperforming the AND operation on the two signals as a set signal S2. Thestate storing signal is supplied to the first storing part 23 as a resetsignal R1. The first storing part 23 stores the operation set valueregarding the task being executed in the instruction executing part 11and outputs the operation set value which is being stored to the counter14. Then, the first storing part 23 sets the operation set value to 0according to the reset signal R1, and sets the operation set value to 1according to the set signal S1. The second storing part 24 stores theoperation set value of the task to be executed next in the instructionexecuting part 11. Then the second storing part 24 sets the operationset value to 0 according to the reset signal R2 and sets the operationset value to 1 according to the set signal S2. The second storing part24 receives a next state designation signal included in the operationsignal. When the next state designation signal is input, the secondstoring part 24 sets the value designated by the next state designationsignal as the operation set value to be stored regardless of the setsignal S2 and the reset signal R2. For example, when the next statedesignation signal indicates 1, the operation set value is set to 1;when the next state designation signal indicates 0, the operation setvalue is set to 0.

Next, the operation of the state controller 13 will be described. In thefirst exemplary embodiment, one bit value is employed as the operationset value. Note that the operation set value and the stored value arenot necessarily the value of one bit but can be formed of a plurality ofbits.

First, description will be made on a first case in which both of thevalues stored in the first storing part 23 and the second storing part24 are 0. Since one of the inputs of the AND circuits 21 and 22 is 0 inthe first case, the set signals S1 and S2 keep 0 for the change of thevalue of the state setting signal or the state storing signal. Insummary, the values stored in the first storing part 23 and the secondstoring part 24 do not change in the first case.

A second case is that one of the values stored in the first storing part23 and the second storing part 24 is 1 and the other is 0. In this case,when the signal input to the AND circuit supplying the set signal to thestoring part in which 0 is stored is changed from 0 to 1, the set signaloutput from the AND circuit becomes 1. Hence, the value of the storingpart in which 0 is stored becomes 1. On the other hand, the reset signalinput to the storing part in which 1 is stored also becomes 1;therefore, the value of the storing part in which 1 is stored is 0. Inthe second case, the values of the two storing parts are apparentlyexchanged. More specifically, when the state storing signal is changedfrom 0 to 1 in a case where 1 is set as the value of the second storingpart 24 and 0 is set as the value of the first storing part 23, the setsignal S1 becomes 1 based on the value (in this case, 1) stored in thesecond storing part 24; hence, the value of the first storing part 23 isset to 1. Since the reset signal R2 is set to 1, the value of the secondstoring part 24 is set to 0. On the other hand, when the state settingsignal is changed from 0 to 1 in a case where 0 is set as the value ofthe second storing part 24 and 1 is set as the value of the firststoring part 23, the value of the second storing part 24 is set to 1 asthe set signal S2 becomes 1 based on the value (in this case, 1) storedin the first storing part 23. The value of the first storing part 23 isset to 0 as the reset signal R1 is set to 1.

A third case is that both of the values stored in the first storing part23 and the second storing part 24 are 1. In the third case, both of theinputs of the AND circuit 22 are 1 when the state storing signal changesfrom 0 to 1; therefore, the set signal S2 becomes 1. Hence, the valuestored in the second storing part 24 keeps 1. On the other hand, thevalue stored in the second storing part 24 becomes 0 as the reset signalR1 supplied to the first storing part 23 changes from 0 to 1 accordingto the state storing signal. Further, when the state setting signal israised from 0 to 1, both of the inputs of the AND circuit 21 become 1;therefore, the set signal S1 becomes 1. Accordingly, the value stored inthe first storing part 23 keeps 1. On the other hand, the reset signalR2 supplied to the second storing part 24 changes from 0 to 1 inaccordance with the state setting signal; therefore, the value stored inthe second storing part 24 becomes 0. In the third case, when the statestoring signal becomes 1, the value of the first storing part 23 becomes0 and the second storing part 24 keeps the value of 1. When the statesetting signal becomes 1, the value of the second storing part 24becomes 0 and the value of the first storing part 23 becomes 1. Insummary, the value of the first storing part 23 is 0 when the statestoring signal becomes 1, and the value of the second storing part 24becomes 0 when the state setting signal becomes 1.

Next, the operation of the data processing device 1 will be describedwith reference to FIG. 3, which is a flow chart showing the operation ofthe data processing device 1. A first step in the example shown in FIG.3 is the scheduling operation of the normal task which is executed nextin the management task (step S1). It is determined in the managementtask whether the normal task which is executed next is the measurementobject or not (step S2). When it is determined that the normal taskwhich is executed next is the measurement object in step S2 (step S2:Yes), the instruction executing part 11 outputs the next statedesignation signal and sets the first value (1, for example) as theoperation set value indicating that the next normal task is themeasurement object in the second storing part 24 (step S3). When it isdetermined in step S2 that the normal task which is executed next is outof the measurement object (step S2: No), the instruction executing part11 outputs the next state designation signal and sets the second value(0, for example) as the operation set value indicating that the nextnormal task is the measurement object in the second storing part 24(step S4). Then the management task executes the instruction of callingthe normal task (step S5).

Then, the state controller 13 sets the operation set value stored in thesecond storing part 24 to the operation set value of the first storingpart 23 according to the signal of calling the normal task generatedalong with the switch of the tasks in step S5 to set the value of thesecond storing part 24 to 0 (step S6). When the operation set valuestored in the first storing part 23 is 1 (step S7: Yes), the counterstarts the operation. Then the normal task which is called is executed(step S9). On the other hand, when the operation set value stored in thefirst storing part 23 is 0 (step S7: No), the counter does not measure,and the instruction executing part 11 executes the task withoutperforming the measurement of the task (step S9).

Then, the instruction of calling management task is executed in thenormal task being executed in the instruction executing part 11 (stepS10). The instruction executing part 11 outputs the signal of callingthe management task according to the execution of the instruction ofcalling the management task. The state controller 13 stores theoperation set value stored in the first storing part 23 in the secondstoring part 24 in accordance with the instruction of calling themanagement task. The value stored in the first storing part 23 is set to0. The counter 14 stops the operation as the value stored in the firststoring part 23 becomes 0 (step S11). Then, the instruction executingpart 11 moves the task to be executed from the normal task to themanagement task, and again performs the scheduling operation of themanagement task.

Now, the operation of the data processing device 1 along with the flowchart of FIG. 3 will be described along with a timing chart shown inFIG. 4. As shown in FIG. 4, in the data processing device 1, theinstruction executing part 11 outputs the next state designation signalbased on the scheduling operation of the management task at timing T1.The example in FIG. 4 shows a case in which the normal task to beexecuted next is the measurement object. At this time, the next statedesignation signal output from the instruction executing part 11designates the value of 1. At timing T2, the operation set valueindicating the first value is set in the second storing part 24 inaccordance with the next state designation signal. When the instructionof calling normal task is executed in the management task, the signal ofcalling the normal task is raised. Further, the state setting signal,the set signal S1, and the reset signal R2 are raised in accordance withthe rising of the signal of calling the normal task. Then, the statesetting signal, the set signal S1, and the reset signal R2 are fallen inaccordance with the falling of the signal of calling the normal task attiming T3. Then, the operation set value stored in the second storingpart 24 moves to the first storing part 23 and 0 is set in the secondstoring part 24 in the state controller 13 in accordance with thefalling of the set signal S1 and the reset signal R2 at timing T3.Further, the operation set value stored in the first storing part 23becomes the first value due to the operation of the state controller 13,whereby the counter 14 starts the operation.

Next, when the instruction of calling the management task is executed inthe normal task, the signal of calling the management task is raised.Further, the state storing signal, the set signal S2, and the resetsignal R1 are raised in accordance with the rising of the signal ofcalling the management task. Then, the state storing signal, the setsignal S2, and the reset signal R1 are fallen in accordance with thefalling of the signal of calling the normal task at timing T4. Then, theoperation set value stored in the first storing part 23 moves to thesecond storing part 24 and 0 is set in the first storing part 23 in thestate controller 13 in accordance with the falling of the set signal S2and the reset signal R1 at timing T4. The value of the first storingpart 23 becomes 0 due to the operation of the state controller 13,whereby the counter 14 stops the operation.

Now, the operation of the data processing device 1 will be describedfurther with reference to FIG. 5, which is a sequence diagram showing anexample of the operation of the data processing device 1. FIG. 5 showsan example in which the normal tasks A and C which are the tasks of themeasurement object, and the normal task B which is out of themeasurement object are executed in the instruction executing part 11.Further, the counter 14 measures the execution time of the task of themeasurement object by counting the operation clock. The example shown inFIG. 5 is the operation realized by repeatedly executing the flow chartshown in FIG. 3.

As shown in FIG. 5, 0 is set in the first storing part 23 during a timeat which the management task out of the measurement object is executed.Therefore, the counter 14 does not measure. Further, since the normaltask A which is to be executed next is the task of the measurementobject, the instruction executing part 11 executing the management taskoutputs the next state designation signal, and the operation set valuestored in the second storing part 24 is set to the first value (1, forexample). When the instruction of calling the normal task is executed inthe management task, the instruction executing part 11 changes theexecuted task the management task to the normal task A. The operationset value stored in the second storing part 24 moves to the firststoring part 23 in synchronization with the switch of the tasks, and 0is set in the second storing part 24. Accordingly, since the first valueis set as the operation set value in the first storing part 23, thecounter 14 starts the operation in synchronization with the switch ofthe tasks to measure the execution time of the normal task A. The timewhich is measured here is called time UTA.

When the instruction of calling the management task is executed in thenormal task A, the instruction executing part 11 changes the executedtask the normal task A to the management task. The instruction executingpart 11 outputs the signal of calling the management task along with theexecution of the instruction of calling the management task.Accordingly, the operation set value stored in the first storing part 23is moved to the second storing part 24 in synchronization with thesignal of calling the management task to set 0 in the first storing part23 in the state controller 13. Accordingly, the value of the firststoring part 23 becomes the second value indicating a state in which themeasurement is stopped, whereby the counter 14 stops the operation.

Next, since the normal task B which is to be executed next is the taskout of the measurement object, the instruction executing part 11executing the management task outputs the next state designation signaland sets the operation set value stored in the second storing part 24 tothe second value (0, for example). When the instruction of calling thenormal task is executed in the management task, the instructionexecuting part 11 switches the task to be executed from the managementtask to the normal task B. The operation set value stored in the secondstoring part 24 moves to the first storing part 23 in synchronizationwith the switch of the tasks, and 0 is set in the second storing part24. Accordingly, since the second value is set in the first storing part23 as the operation set value, the counter 14 keeps the stop state evenwhen the tasks are switched.

When the instruction of calling the management task is executed in thenormal task B, the instruction executing part 11 switches the task to beexecuted from the normal task B to the management task. The instructionexecuting part 11 outputs the signal of calling the management taskalong with the instruction of calling the management task. Accordingly,the operation set value stored in the first storing part 23 is moved tothe second storing part 24 in synchronization with the signal of callingthe management task to set 0 in the first storing part 23 in the statecontroller 13. Accordingly, the value of the first storing part 23becomes the second value indicating the state in which the measurementis stopped, whereby the counter 14 keeps the stop state.

Next, since the normal task C which is to be executed next is the taskof the measurement object, the instruction executing part 11 executingthe management task outputs the next state designation signal to set theoperation set value stored in the second storing part 24 to the firstvalue (1, for example). When the instruction of calling the normal taskis executed in the management task, the instruction executing part 11switches the task to be executed from the management task to the normaltask C. Further, the operation set value stored in the second storingpart 24 moves to the first storing part 23 in synchronization with theswitch of the tasks, and 0 is set in the second storing part 24.Accordingly, since the first value is set as the operation set value inthe first storing part 23, the counter 14 starts the operation insynchronization with the switch of the tasks to measure the executiontime of the normal task A. The time measured at this time is called timeUTC.

When the instruction of calling the management task is executed in thenormal task C, the instruction executing part 11 switches the task to beexecuted from the normal task C to the management task. Further, theinstruction executing part 11 outputs the signal of calling themanagement task based on the execution of the instruction of calling themanagement task. Accordingly, the operation set value stored in thefirst storing part 23 is moved to the second storing part 24 insynchronization with the signal of calling the management task to set 0in the first storing part 23 in the state controller 13. Accordingly,the value of the first storing part 23 becomes the second valueindicating the state in which the measurement is stopped, whereby thecounter 14 stops the operation.

The above description concerns the operation of a case in which themanagement task and the normal task are switched. In the followingdescription, the operation of the data processing device 1 of a case inwhich the interruption task interrupts the management task or the normaltask will be described. FIG. 6 shows a flow chart showing the operationof the data processing device 1 when the interruption task isinterrupted.

The first step of the example shown in FIG. 6 is a state in which themanagement task or the normal task is being executed in the instructionexecuting part 11 (step S21). When the interruption generation signal isinput to the instruction executing part 11 during a time at which themanagement task or the normal task is being executed, the instructionexecuting part 11 moves the task to be executed to the interruption taskgenerating the interruption generation signal (step S22). Theinstruction executing part 11 outputs the signal of calling themanagement task in accordance with the interruption generation signal.The state controller 13 stores the operation set value stored in thefirst storing part 23 in the second storing part 24 in accordance withthe instruction of the management task. Further, the value stored in thefirst storing part 23 is set to 0. The counter 14 stops the operation asthe value stored in the first storing part 23 becomes 0 (step S23). Thenthe instruction executing part 11 executes the interruption task (stepS24).

The interruption return instruction is executed in the interruption taskexecuted instep S24. The instruction executing part 11 outputs theinterruption return signal in accordance with the execution of theinterruption return instruction. Then, the state controller 13 sets theoperation set value stored in the second storing part 24 to theoperation set value of the first storing part 23, and sets the value ofthe second storing part 24 to 0 (step S26). When the operation set valuestored in the first storing part 23 is 1 (step S27: Yes), the counterstarts the operation. Then, the normal task or the management task whichis called is executed. On the other hand, when the operation set valuestored in the first storing part 23 is 0 (step S27: No), the counterdoes not measure, and the instruction executing part 11 executes thenormal task or the management task which is called without performingthe measurement of the task.

Now, the operation of the data processing device 1 referring to the flowchart of FIG. 6 will be described along with a timing chart shown inFIG. 7. FIG. 7 shows an example in which the interruption taskinterrupts the execution of the normal task. As shown in FIG. 7, whenthe interruption generation signal is raised during a time at which thenormal task is being executed, the state storing signal, the set signalS2, and the reset signal R1 are raised in accordance with the rising ofthe signal in the data processing device 1. Then, the state storingsignal, the set signal S2, and the reset signal R1 are fallen inaccordance with the falling of the interruption generation signal attiming T11. Then, the operation set value stored in the first storingpart 23 moves to the second storing part 24 and 0 is set in the firststoring part 23 in the state controller 13 in accordance with thefalling of the set signal S2 and the reset signal R1 at timing T11.Since the operation set value stored in the first storing part 23 is thesecond value due to the operation of the state controller 13, thecounter 14 stops the operation.

When the interruption return instruction is executed in the interruptiontask, the interruption return signal is raised. Further, the statesetting signal, the set signal S1, and the reset signal R2 are raised inaccordance with the rising of the interruption return signal. The statesetting signal, the set signal S1, and the reset signal R2 are fallen inaccordance with the falling of the interruption return signal at timingT12. The operation set value stored in the second storing part 24 movesto the first storing part 23 and 0 is set in the second storing part 24in the state controller 13 in accordance with the falling of the setsignal S1 and the reset signal R2 at timing T12. Since the value of thefirst storing part 23 becomes the first value due to the operation ofthe state controller 13, the counter 14 starts the operation.

Now, the operation of the data processing device 1 will be describedfurther with reference to FIG. 8, which is a sequence diagram showing anexample of the operation of a case in which the interruption task isexecuted in the data processing device 1. FIG. 8 shows an example inwhich the normal task which is the task of the measurement object, themanagement task which is the task out of the measurement object, and theinterruption task are executed in the instruction executing part 11. InFIG. 8, the counter 14 measures the execution time of the task of themeasurement object by counting the operation clock. FIG. 8 shows anexample in which the interruption task is interrupted during a time atwhich the user task is being executed and the measurement time isinterrupted.

As shown in FIG. 8, the operation set value indicates 0 during a time atwhich the management task out of the measurement object is executed;therefore, the counter 14 does not operate at this time. Further, theinstruction executing part 11 executing the management task outputs thenext state designation signal to set the first value as the operationset value in the second storing part 24 since the user task to beexecuted next is the task of the measurement object. When theinstruction of calling the normal task is executed in the managementtask, the task executed in the instruction executing part 11 is switchedfrom the management task to the normal task. Further, the operation setvalue stored in the second storing part 24 moves to the second storingpart 24 in synchronization with the switch of the tasks, and 0 is set inthe second storing part 24. Since the operation set value stored in thefirst storing part 23 becomes 1, the counter 14 starts the operation insynchronization with the switch of the tasks and measures the executiontime of the user task. The time measured here is called time UT1.

When the interruption request by the interruption task is generatedduring a time at which the normal task is executed, the instructionexecuting part 11 switches the task to be executed from the normal taskto the interruption task based on the interruption generation signal.Further, the operation set value stored in the first storing part 23 ismoved to the second storing part 24 in the state controller 13 and 0 isset as the value of the first storing part 23 based on the interruptiongeneration signal. Accordingly, the operation set value during a periodat which the normal task is executed is stored in the second storingpart 24. Since 0 is stored in the first storing part 23, the counter 14stops the operation in synchronization with the switch of the tasks.Here, in the data processing device 1, the count value output from thecounter 14 when the tasks are switched is stored in the count valuestoring part based on the interruption generation signal.

Along with the advancement of the interruption task, the interruptiontask executes the interruption return instruction. Accordingly, the taskexecuted by the instruction executing part 11 becomes the normal task ofthe branch source. The instruction executing part 11 outputs theinterruption return signal in accordance with the execution of theinterruption return instruction. The state controller 13 moves theoperation set value stored in the second storing part 24 to the firststoring part 23 to set 0 in the second storing part 24 in accordancewith the interruption return signal. Accordingly, the operation setvalue stored in the first storing part 23 becomes the first value.Further, in the data processing device 1, the count value stored in thecount value storing part 15 is set in the counter 14 in accordance withthe interruption return signal. Then the counter 14 restarts themeasurement of the execution time of the user task in accordance withthe switch of the operation set values. The time measured by the counter14 after restart of the measurement is called time UT2.

When the instruction of calling the management task is executed in thenormal task, the instruction executing part 11 switches the task to beexecuted from the normal task to the management task. At this time, theinstruction executing part 11 outputs the signal of calling themanagement task. The state controller 13 moves the operation set valuestored in the first storing part 23 to the second storing part 24 to set0 as the value of the first storing part 23 based on the signal ofcalling the management task.

From the above description, the data processing device 1 according tothe first exemplary embodiment stores the operation set value regardingthe normal task to be executed next in the second storing part 24 beforethe task is switched from the management task to the normal task. Thenthe operation set value stored in the second storing part 24 is moved tothe first storing part 23 in synchronization with the switch of thetasks. Accordingly, the counter 14 is able to measure the executionstate of the normal task without error. Even when the interruption taskis interrupted during a time at which the normal task is executed, theoperation set value stored in the first storing part 23 is stored in thesecond storing part 24 in synchronization with the switch of the tasks,and the operation set value stored in the second storing part 24 ismoved back to the first storing part 23 in synchronization with theswitching from the interruption task to the normal task. Accordingly,even in a case in which the interruption task is interrupted during atime at which the normal task is executed and the execution time of thenormal task is divided, it is possible to execute the measurement of thenormal task with accuracy. For example, in the example shown in FIG. 8,the measurement time UT1 and the measurement time UT2 are added so as tobe able to measure the time of the normal task with accuracy.

In the data processing device 1, the counter 14 measures the operationclock so as to be able to measure the execution time of the task. Atthis time, it is detected in the data processing device 1 using thecomparator 17 that the count value of the counter 14 reaches thecomparison value to output the detection result as the measurementinterruption request signal, so as to be able to operate the measurementcircuit 12 as a timer. Further, when the counter 14 notifies the eventnotification signal, the error generated during the execution of thetask can be counted, for example. Since the counter 14 measures theevent notification signal to obtain the information regarding in whichtask the error occurs, it is possible to improve the efficiency ofdebugging of the program regarding the tasks, for example.

Further, as shown in the example of FIG. 5, in the data processingdevice 1, it is determined in the instruction executing part 11executing the management task whether the normal task to be executednext is the measurement object or not, so as to set the operation setvalue in the second storing part 24 based on the determination resultbefore the execution of the next normal task. Then, the operation setvalue stored in the second storing part 24 is stored in the firststoring part 23 in synchronization with the switch of the tasks in theinstruction executing part 11. Accordingly, any task can be selected asthe measurement object without depending on the execution mode of thenormal task. As such, the normal task which is the measurement object isselected as appropriate, whereby only the state of the execution of thenormal task which is currently been examined can be measured withoutperforming the measurement of the state of the execution on the normaltask where the examination has already been completed, for example.Accordingly, only the information needed for debugging of the programregarding the normal task can be obtained, for example, which improvesthe efficiency of the debugging of the program.

Furthermore, it is possible to omit the setting regarding the normaltask which has no limitation in the execution time in the multi-taskoperation. The related art requires the operation of storing the timeunduly long as the execution time in the comparison value storing part,for example, when there is included in the same execution mode a normaltask which has no limitation in the execution time. However, accordingto the data processing device 1 of the first exemplary embodiment, it ispossible to select whether to perform the measurement for each normaltask. Therefore, there is no need to set the comparison value regardingthe normal task which has no limitation included in the same executionmode. Accordingly, the data processing device 1 according to the firstexemplary embodiment makes it possible to reduce the number of processesin performing the setting of the task schedule.

Second Exemplary Embodiment

In a data processing device according to the second exemplaryembodiment, the operation state of the interruption task is measuredwhen the interruption task in the first exemplary embodiment is themeasurement object. Since the interruption task is not the object of theschedule by the management task, it is not possible to set the operationset value based on the management task. In such a case, the instructionexecuting part 11 rewrites the operation set value in accordance withthe saving operation executed in the interruption task, so that thecounter 14 is able to measure the execution state of the interruptiontask. Further, in the saving operation, the operation set valuecorresponding to the normal task is saved in the memory as a savingcontext when the interruption task is executed. Further, theinterruption task executes the recovery operation which forms a pairwith the saving operation. In the recovery operation, the operation ofwriting back the operation set value which is saved as the savingcontext in the second storing part 24 is executed.

FIG. 9 shows a block diagram of a data processing device 2 according tothe second exemplary embodiment. As shown in FIG. 9, in the savingoperation in the data processing device 2, the instruction executingpart 11 reads out the operation set value stored in the second storingpart 24 of the state controller 13 and the count value stored in thecount value storing part 15 as the saving information. Then theinstruction executing part 11 adds the information of the executionstate of the normal task corresponding to the saving information to thesaving information to store the information in the memory 10 as thesaving context. Further, in the recovery operation, the instructionexecuting part 11 reads out the information saved as the saving contextbefore the execution of the normal task. The instruction executing part11 writes back the operation set value to the second storing part 24.The operation set value is included in the saved information which issaved using the operation signal. The instruction executing part 11writes back the count value included in the saved information to thecount value storing part 15.

In the second exemplary embodiment, the operation signal output from theinstruction executing part 11 includes a current state designationsignal. The current state designation signal is input to the firststoring part 23. FIG. 10 shows a block diagram of the state controller13 according to the second exemplary embodiment. As shown in FIG. 10, inthe state controller 13 according to the second exemplary embodiment,the current state designation signal is input to the first storing part23. Upon receiving the current state designation signal, the firststoring part 23 stores the value designated by the current statedesignation signal as the operation set value regardless of the valuesof the set signal S1 and the reset signal R1.

Now, FIG. 11 shows a flow chart showing the operation of the dataprocessing device 2 according to the second exemplary embodiment. Asshown in FIG. 11, the flow chart regarding the interruption task shownin FIG. 6 is changed to realize the saving operation and the recoveryoperation in the data processing device 2. More specifically, the savingoperation and the recovery operation are added to the operation flow ofthe interruption task shown in FIG. 6.

As shown in FIG. 11, in the data processing device 2, the instructionexecuting part 11 is moved to the interruption prohibition stateprohibiting the interruption from other interruption tasks (step S31)before the execution of the interruption task (after step S23). Then theinstruction executing part 11 executes the saving operation inaccordance with the interruption task (step S32). After that, theinstruction executing part 11 cancels interruption prohibition (stepS33). After the cancel of the interruption prohibition in step S33, theinstruction executing part 11 executes the interruption task (step S24).The instruction executing part 11 executes the recovery operation beforeexecuting the interruption return instruction (step S34), and then theinterruption return instruction is executed (step S25).

Now, FIG. 12 shows a sequence diagram showing the operation of the dataprocessing device according to the second exemplary embodiment. In FIG.12, the saving operation and the recovery operation of the secondexemplary embodiment are applied to the sequence diagram in FIG. 8. Thedifferent part from that of the first exemplary embodiment will bedescribed in the following description. As shown in FIG. 12, in thesecond exemplary embodiment, the instruction executing part 11 outputsthe current state designation signal in accordance with the savingoperation executed by the interruption task to set the operation setvalue indicating the first value in the first storing part 23. Then thecounter 14 measures the execution time of the interruption task insynchronization with the change of the operation set value by thecurrent state designation signal. The execution time of the interruptiontask which is measured here is called time ITA. Further, the operationset value of the normal task stored in the second storing part 24 isstored in the memory 10 as the saving context in accordance with thesaving operation of the interruption task.

After that, when the recovery operation of the interruption task isexecuted before executing the interruption return instruction, theoperation set value in accordance with the normal task is written backfrom the saving context to the second storing part 24. When theexecution of the normal task is restarted, the operation set value ofthe second storing part 24 is moved to the first storing part 23 insynchronization with the restart of the operation of the normal task.Accordingly, the counter 14 restarts the operation in synchronizationwith the restart of the operation of the normal task to perform themeasurement of the execution time of the normal task.

From the above description, according to the data processing device 2 ofthe second exemplary embodiment, the instruction executing part 11rewrites the value stored in the first storing part 23 in accordancewith the saving operation, whereby it is possible to measure theexecution state even in the interruption task which is out of the objectof the schedule performed in the management task. At this time, theperiod from when the saving operation is executed to when the operationset value is rewritten cannot be measured by the counter 14. Therefore,the accuracy of the measurement time in the second exemplary embodimentis inferior to that in the first exemplary embodiment. However, bysetting the interruption prohibition period set in the saving operationin advance, the degrading of the accuracy can be prevented. For example,when the interruption prohibition period is set to 10 msec, 10 msec isadded to the time measured by the counter 14, so as to prohibitdegrading of the accuracy.

Further, in the data processing device 2 according to the secondexemplary embodiment, the interruption task executes the savingoperation and the recovery operation, and the instruction executing part11 saves and recovers the stored value and the count value in accordancewith the saving operation and the recovery operation. Accordingly, inthe data processing device 2, it is possible to avoid the problem thatthe operation set value stored regarding the normal task stored in thesecond storing part 24 is erased by the interruption task.

Although the saving operation and the recovery operation are executed bythe interruption task in the second exemplary embodiment, the executionof the saving operation and the recovery operation may be applied to thenormal task as well. Accordingly, the saving operation and the recoveryoperation can also be executed even in the normal task.

Third Exemplary Embodiment

A third exemplary embodiment shows a case in which the interruption taskperforms multiple interruptions. In the third exemplary embodiment, theinstruction executing part 11 executes an interruption task A whichinterrupts the normal task and an interruption task B which interruptsthe interruption task A in addition to the management task and thenormal task. Note that the interruption task A is the task of themeasurement object and the interruption task B is the task out of themeasurement object. As is the same as the second exemplary embodiment,the interruption tasks A and B also perform the saving operation and therecovery operation in the third exemplary embodiment.

The operation of the data processing device will be described withreference to FIG. 13, which is a sequence diagram showing the operationof the data processing device according to the third exemplaryembodiment. In the example shown in FIG. 13, the operation regarding themanagement task is omitted for the sake of simplicity. In the normaltask shown in FIG. 13, the operation is controlled by the managementtask, as is the same as the first exemplary embodiment. Since FIG. 13 isa variant example of the sequence diagram shown in FIG. 12, only a partdifferent from that of FIG. 12 will be described below.

As shown in FIG. 13, the operation set value is 1 during a time at whichthe interruption task A is executed; therefore, the counter 14 measuresthe execution time of the interruption task A. When the interruptiongeneration signal is generated during a time at which the interruptiontask A is executed, the task to be executed is switched from theinterruption task A to the interruption task B in the instructionexecuting part 11. Along with this switch of the tasks, the operationset value stored in the first storing part 23 is moved to the secondstoring part 24 in the state controller 13. At this time, 0 is set inthe first storing part 23. Accordingly, the counter 14 stops themeasurement of the execution time of the task, and the count valuestoring part 15 stores the count value. Then, when the interruption taskB is executed, the interruption task B executes the saving operation. Inaccordance with this saving operation, the instruction executing part 11reads out the operation set value regarding the interruption task Astored in the second storing part 24 to store the operation set value inthe memory 10 as the saving context.

Then, along with the advancement of the execution of the interruptiontask B, the interruption task B executes the recovery operation beforecompletion of the task. The instruction executing part 11 reads out thesaving context from the memory 10 in accordance with the execution ofthe recovery operation and writes back the operation set valuecorresponding to the saved interruption task A to the second storingpart 24. This task A is saved with the operation signal. Then, theinterruption task B executes the interruption return instruction. Inaccordance with the interruption return instruction, the instructionexecuting part 11 outputs the interruption return signal. In accordancewith the interruption return instruction, the state controller 13 movesthe operation set value regarding the interruption task A stored in thesecond storing part 24 to the first storing part 23. Accordingly, thefirst value is set in the first storing part 23, and the counter 14restarts the count of the operation state of the interruption task A inaccordance with the switch of the tasks.

From the above description, according to the data processing device ofthe third exemplary embodiment, even when the multiple interruption ofthe interruption task occurs, the task which is the measurement objectand the task out of the measurement object can be divided without fail.In other words, even when the execution time of the interruption task isdivided, it is possible to perform the measurement of the task of themeasurement object without fail according to the data processing deviceof the third exemplary embodiment.

Note that the present invention is not limited to the above exemplaryembodiments but can be changed as appropriate without departing from thespirit of the present invention. For example, the structure of theoperation controller is not limited to the above exemplary embodimentsbut can be changed as appropriate depending on the data format of thestored values and the operation set values to be stored.

The first to third exemplary embodiments can be combined as desirable byone of ordinary skill in the art.

While the invention has been described in terms of several exemplaryembodiments, those skilled in the art will recognize that the inventioncan be practiced with various modifications within the spirit and scopeof the appended claims and the invention is not limited to the examplesdescribed above.

Further, the scope of the claims is not limited by the exemplaryembodiments described above.

Furthermore, it is noted that, Applicant's intent is to encompassequivalents of all claim elements, even if amended later duringprosecution.

What is claimed is:
 1. A data processing device, comprising: aninstruction execution unit that executes a first task, a second task andan interrupt task; a counter that counts an execution time of one of thefirst task and the interrupt task; a first storage unit that stores aset value to start the counter when the execution unit executes one ofthe first task and the interrupt task; a second storage unit that storesthe set value stored in the first storage unit when the instructionexecution unit switches from an execution of the first task to anexecution of the second task; and a memory that stores the set valuestored in the first storage unit when the instruction unit switches fromthe execution of the first task to an execution of the interrupt task,wherein, when the instruction execution unit switches from the executionof the second task to the execution of the first task, the first storageunit stores the set value stored in the second storage unit, andwherein, when the instruction execution unit switches from the executionof the interrupt task to the execution of the first task, the firststorage unit stores the set value stored in the memory.
 2. The dataprocessing device according to claim 1, wherein, when the instructionexecution unit switches from the execution of the first task to theexecution of the interrupt task, the instruction execution unit executesa saving operation and the second storage unit stores the set valuestored in the first storage unit, and wherein the memory stores the setvalue stored in the second storage unit when the saving operation isexecuted.
 3. The data processing device according to claim 1, wherein,when the instruction execution unit switches from the execution of theinterrupt task to the execution of the first task, the instructionexecution unit executes a recovery operation and the second storage unitstores the set value stored in the memory, and wherein the first storageunit stores the set value stored in the second storage unit when theinstruction execution unit executes the first task.
 4. The dataprocessing device according to claim 1, wherein the counter starts tocount the execution time in synchronization with a time when the setvalue is set.
 5. The data processing device according to claim 1,wherein, when the instruction unit executes the interrupt task, aninterruption prohibition period is set, and wherein the execution timeof the interrupt task counted by the counter is adjusted by theinterruption prohibition period.
 6. The data processing device accordingto claim 1, wherein each of the first and second storage units includesa set terminal to set the set value and a reset terminal to reset theset value.